package com.wanghua.mall.user.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.web.bind.annotation.*;

import com.wanghua.mall.user.entity.UserCollectSubjectEntity;
import com.wanghua.mall.user.service.UserCollectSubjectService;
import com.wanghua.common.utils.PageUtils;
import com.wanghua.common.utils.R;

import javax.annotation.Resource;



/**
 * 用户收藏的专题活动
 *
 * @author wanghua
 * @email 2367279431@qq.com
 * @date 2021-08-24 18:51:22
 */
@RestController
@RequestMapping("/user/usercollectsubject")
public class UserCollectSubjectController {

    @Resource
    private UserCollectSubjectService userCollectSubjectService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userCollectSubjectService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		UserCollectSubjectEntity userCollectSubject = userCollectSubjectService.getById(id);
        return R.ok().put("userCollectSubject", userCollectSubject);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserCollectSubjectEntity userCollectSubject){
		userCollectSubjectService.save(userCollectSubject);
        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody UserCollectSubjectEntity userCollectSubject){
		userCollectSubjectService.updateById(userCollectSubject);
        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		userCollectSubjectService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
